package io.github.shang11925.sbvuewelearn.service.impl;

import io.github.shang11925.sbvuewelearn.dao.TextContentsRepository;
import io.github.shang11925.sbvuewelearn.dto.TextContentsDTO;
import io.github.shang11925.sbvuewelearn.entity.TextContents;
import io.github.shang11925.sbvuewelearn.service.TextContentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TextContentsServiceImpl implements TextContentsService {
    @Autowired
    TextContentsRepository textContentsRepository;


    @Override
    public List<TextContents> findBySectionId(Long sectionId) {return textContentsRepository.findBySectionId(sectionId);}

    @Override
    public void add(TextContentsDTO textContentsDTO) {
        TextContents textContents = new TextContents();
        textContents.setContent(textContentsDTO.getContent());
        textContents.setSectionId(textContentsDTO.getSectionId());

        textContentsRepository.save(textContents);
    }
}
